package com.appspot.aliga.openligadb;

import java.util.Comparator;

import com.appspot.aliga.persistence.LeagueTableEntry;

public class LeagueEntryComperator implements
		Comparator<LeagueTableEntry> {

	@Override
	public int compare(LeagueTableEntry le1, LeagueTableEntry le2) {
		if (le1.getPoints() == le2.getPoints()) {
			if(le1.getGoals() == le2.getGoals()) {
				if(le1.getGoalesScored() == le2.getGoalesScored()) {
					return le2.getWins() - le1.getWins();
				}
				return le2.getGoalesScored() - le1.getGoalesScored();
			}
			return le2.getGoals()- le1.getGoals();
		}
		
		return le2.getPoints()- le1.getPoints();
	}

}
